package cn.ziyoufa.smart.smartschool.net;

import cn.ziyoufa.smart.smartschool.db.SPManager;
import cn.ziyoufa.smart.smartschool.manager.SchemeManager;
import cn.ziyoufa.smart.smartschool.module.power.BasePowerModel;
import cn.ziyoufa.smart.smartschool.okhttp.CommonOkHttpClient;
import cn.ziyoufa.smart.smartschool.okhttp.listener.DisposeDataHandle;
import cn.ziyoufa.smart.smartschool.okhttp.listener.DisposeDataListener;
import cn.ziyoufa.smart.smartschool.okhttp.request.CommonRequest;
import cn.ziyoufa.smart.smartschool.okhttp.request.RequestParams;
import cn.ziyoufa.smart.smartschool.webview.route.Router;

/**
 * 创建人 ： 赵泽东
 * 创建时间：2018/11/22
 *
 * @param
 * @param
 */
public class RequestCenter {
    //根据参数发送所有post请求
    public static void postRequest(String url , RequestParams params, DisposeDataListener listener, Class<?> clazz){
        CommonOkHttpClient.post(CommonRequest.createPostRequest(url,params),new DisposeDataHandle(listener,clazz));
    }
    //根据参数发送所有post请求
    public static void getRequest(String url , RequestParams params, DisposeDataListener listener, Class<?> clazz){
        CommonOkHttpClient.get(CommonRequest.createGetRequest(url,params),new DisposeDataHandle(listener,clazz));
    }

    public static void sendPowerOnRecord(String startUpTime, DisposeDataListener listener){
        RequestParams params = new RequestParams();
        params.put("token",  SPManager.getInstance().getString("token", ""));
        params.put("startUpTime",  startUpTime);
        RequestCenter.postRequest(Router.SERVER_START_UP, params, listener, BasePowerModel.class);
    }

    public static void sendShutDownLog(String content, DisposeDataListener listener){
        RequestParams params = new RequestParams();
        params.put("token",  SPManager.getInstance().getString("token", ""));
        params.put("ele_shutdown_log_s_week",  SchemeManager.getInstance().getSchemeValue().ele_shutdown_week);
        params.put("ele_shutdown_log_e_week",  SchemeManager.getInstance().getE_week());
        params.put("ele_shutdown_log_stime",  SchemeManager.getInstance().getSchemeValue().ele_shutdown_stime);
        params.put("ele_shutdown_log_etime",  SchemeManager.getInstance().getSchemeValue().ele_shutdown_etime);
        params.put("ele_shutdown_log_second",  String.valueOf(SchemeManager.getInstance().getTimeReduce()));
        params.put("ele_shutdown_db_content",  content);
        RequestCenter.postRequest(Router.SERVER_SHUT_DOWN_LOG, params, listener, BasePowerModel.class);
    }
}
